home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / fortran / yaf77-1.1 / yaf77-1 / yaf77 / F77ext / etime.c next >
Encoding:
C/C++ Source or Header  |  1996-01-25  |  870 b   |  43 lines

  1. /*
  2.    From elgin@claudia.spectral.com (Jim Elgin)
  3. */
  4.  
  5. /*  supply "etime" fortran routine
  6.  
  7.  NAME
  8.       etime - return elapsed execution time
  9.  
  10.  SYNOPSIS
  11.       REAL function etime (tarray)
  12.       REAL tarray(2)
  13.  
  14.  DESCRIPTION
  15.       This routine returns elapsed runtime in seconds for the calling
  16.       process.
  17.  
  18.       The argument array returns user time in the first element and system
  19.       time in the second element.  The function value is the sum of user and
  20.       system time.
  21.  
  22.       The resolution of all timing is 1/CLK_TCK seconds, where CLK_TCK is
  23.       processor dependent.
  24. */
  25.  
  26. float etime_(tarray)
  27. float *tarray;
  28. {
  29. #include <unistd.h>
  30. #include <sys/times.h>
  31. struct tms buf;
  32. float t1, t2, den, tot;
  33.  
  34. times(&buf);
  35. t1 = buf.tms_utime;
  36. t2 = buf.tms_stime;
  37. den = sysconf(_SC_CLK_TCK);
  38. *tarray = t1/den;
  39. *(tarray+1) = t2/den;
  40. tot = *tarray + *(tarray+1);
  41. return tot;
  42. }
  43.